const Base = require('./index')
const logger = require('../utils/console-logger')

const table = 'media_season'
const columnMap = {
    'syncTime': 'sync_time',
}


class MediaSeason extends Base {
    constructor(){
        super(table, columnMap)
    }
    
    async getByTmdbidSeason(tmdbid, season) {
        const getByTmdbidSeasonQuery = this.knex.select().from(this.table).where('tmdbid', tmdbid).where('season', season)
        logger.debug('getByTmdbidSeasonQuery sql: ', getByTmdbidSeasonQuery.toString())
        const rows = await getByTmdbidSeasonQuery
        return rows && rows.length > 0 ? this.warpModel(rows[0]) : null
    }
}

module.exports = new MediaSeason()